<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>猪八借</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <script src="./script/vue.min.js"></script>
    <style type="text/css">
        html,
        body {
            height: 100%;
        }

        #wrap {
            height: 100%;
            display: -webkit-box;
            display: -webkit-flex;
            display: flex;
            -webkit-box-orient: vertical;
            -webkit-flex-flow: column;
            flex-flow: column;
        }

        #wrap div {
            width: 80%;
            margin: 20px 10%;
        }
    </style>
</head>

<body>
    <div id="wrap">
        <!-- <div style="margin-top:100px;" @click="goIndex1()" class="aui-btn aui-btn-primary">审核版2</div> -->
        <!-- <div  class="aui-btn aui-btn-success" @click="goIndex2()">正式版2</div> -->
    </div>
</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript">
    apiready = function() {
        init()
        var systemType = api.systemType
        if (systemType === 'ios') {
          var obj = api.require('idfa');
          var idfa = obj.getIDFA();
          $api.setStorage('channel', 'IOSOfficial')
          $api.setStorage('did', idfa)
        } else if (systemType === 'android') {
          var simInfoImp = api.require('simInfoImp')
          $api.setStorage('channel', 'AndroidOfficial')
          simInfoImp.getDeviceId(function(ret) {
            $api.setStorage('did', ret.deviceId)
          });
        }
        // $api.clearStorage('phone')
        // api.setStatusBarStyle({
        //   style: 'light',
        //   color: '#000000'
        // });
        api.refreshHeaderLoadDone()
            // 再点一次退出应用
        api.addEventListener({
                    name:'viewappear'
            },function(ret,err){
                    api.setStatusBarStyle({
                    style: 'light',
                    color: '#000000'
                });
            });
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.toast({
                msg: '再点一次退出应用',
                duration: 2000,
                location: 'bottom'
            });
            api.addEventListener({
                name: 'keyback'
            }, function(ret, err) {
                api.closeWidget({
                    silent: true
                });
            });
            setTimeout(function() {
                exitApp();
            }, 2000)
        });
        var vm = new Vue({
            el: '#wrap',
            data: {},
            methods: {
            },
            mounted: function() {
                let phone2 = $api.getStorage('phone2')
                // if (phone2) { //切换审核
                //   api.openWin({
                //       name: 'page1',
                //       url: './html/audit/home.html',
                //       slidBackEnabled: false
                //   });
                // } else {
                //   api.openWin({
                //       name: 'page1',
                //       url: './html/audit/login.html',
                //       slidBackEnabled: false
                //   });
                // }

                api.openWin({ //切换贷超
                    name: 'page2',
                    url: './html/online/home.html',
                    slidBackEnabled: false
                });
            }
        })
    };


    function init() {
        api.addEventListener({
            name: 'smartupdatefinish'
        }, function(ret, err) {
            alert('更新完成');
            api.rebootApp();
        });
    }


    // 再点一次退出应用
    function exitApp() {
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.toast({
                msg: '再点一次退出应用',
                duration: 2000,
                location: 'bottom'
            });
            api.addEventListener({
                name: 'keyback'
            }, function(ret, err) {
                api.closeWidget({
                    silent: true
                });
            });
            setTimeout(function() {
                exitApp();
            }, 2000)
        });
    }
    setTimeout(function() {
        api.removeLaunchView();
    }, 500);
</script>

</html>
